package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.PersonalInfoXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：2016/10/20 10:12
 * 修改备注：
 * ================================================
 */

public class BusinessTraining {

    /**
     * 发起培训
     *
     * @param activity
     * @param title        培训名称
     * @param traindate    培训日期
     * @param starttime    开始时间
     * @param endtime      结束时间
     * @param provinceCode 省
     * @param cityCode     市
     * @param countyCode   区
     * @param handler
     */
    public static void initiateTraining(Activity activity, String title, String traindate, String starttime, String endtime,
                                        String provinceCode, String cityCode, String countyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("title", title);
        params.put("traindate", traindate);
        params.put("starttime", starttime);
        params.put("endtime", endtime);
        params.put("provinceCode", provinceCode);
        params.put("cityCode", cityCode);
        params.put("countyCode", countyCode);
        params.put("useraccid", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_TRAINING_SAVE, "", params, handler, MSG.MSG_TRAINING_SAVE_SUCCESS, MSG.MSG_TRAINING_SAVE_FIELD);

    }

    /**
     * 培训列表(issign为1 已签到为0未签到)
     *
     * @param activity
     * @param title        培训名称
     * @param traindate    培训日期
     * @param expertName   专家名称
     * @param keyword      匹配关键字
     * @param provinceCode 省
     * @param cityCode     市
     * @param countyCode   区
     * @param handler
     */
    public static void getTrainingList(Activity activity, String page, String limit, String title,
                                       String traindate, String expertName, String keyword, String provinceCode,
                                       String cityCode, String countyCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("mobilephone", UserXML.getMobilePhone(activity));
        params.put("title", title);
        params.put("traindate", traindate);
        params.put("page", page);
        params.put("limit", limit);
        params.put("expertName", expertName);
        params.put("keyword", keyword);
        params.put("provinceCode", provinceCode);
        params.put("cityCode", cityCode);
        params.put("countryCode", countyCode);
//        params.put("useraccid", UserXML.getId(activity));

        OkHttpUtil.post(activity, URL.URL_TRAINING_LIST, "", params, handler, MSG.MSG_TRAINING_LIST_SUCCESS, MSG.MSG_TRAINING_LIST_FIELD);

    }

    /**
     * 培训签到接口
     */
    public static void signForApp(Activity activity, String loginName, String phoneNumber, String traincode, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("loginName", loginName);
        params.put("phoneNumber", phoneNumber);
        params.put("traincode", traincode);

        OkHttpUtil.post(activity, URL.URL_TRAINING_SIGN, "", params, handler, MSG.MSG_TRAINING_SIGN_SUCCESS, MSG.MSG_TRAINING_SIGN_FIELD);
    }


    /**
     * 关注/取消关注接口
     *
     * @param teacherId 被关注讲师
     * @param trainId   被关注培训
     */
    public static void toAddAttention(Activity activity, String teacherId, String trainId, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("teacherId", teacherId);
        params.put("trainId", trainId);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_TO_ADD_ATTENTION_NEW, "", params, handler, MSG.MSG_TO_ADD_ATTENTION_SUCCESS, MSG.MSG_TO_ADD_ATTENTION_FIELD);
    }

    /**
     * 是否关注(isAttend为1 已关注)
     *
     * @param teacherId 被关注讲师
     * @param trainId   被关注培训
     */
    public static void attentionStatus(Activity activity, String teacherId, String trainId, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("teacherId", teacherId);
        params.put("trainId", trainId);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_ATTENTION_STATUS_NEW, "", params, handler, MSG.MSG_ATTENTION_STATUS_SUCCESS, MSG.MSG_ATTENTION_STATUS_FIELD);
    }

    /**
     * 获取培训详情
     *
     * @param trainId 被关注培训ID
     */
    public static void getTrainDetail(Activity activity, String trainId, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("trainId", trainId);
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_TRAIN_DETAIL_NEW, "", params, handler, MSG.MSG_GET_TRAIN_DETAIL_SUCCESS, MSG.MSG_GET_TRAIN_DETAIL_FIELD);
    }

    /**
     * 新版培训列表
     *
     * @param activity
     * @param cityName 城市名
     * @param page
     * @param num
     * @param handler
     */
    public static void getTrainingInCity(Activity activity, String cityName, String page, String num, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("cityName", cityName);
        params.put("page", page);
        params.put("num", num);
        params.put("userId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_TRAINING_IN_CITY_NEW, "", params, handler, MSG.MSG_GET_TRAINING_IN_CITY_SUCCESS, MSG.MSG_GET_TRAINING_IN_CITY_FIELD);
    }


    /**
     * 新版培训列表--搜索
     *
     * @param activity
     * @param keyWords
     * @param page
     * @param num
     * @param handler
     */
    public static void getTrainingByKeywords(Activity activity, String keyWords, String page, String num, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("keyWords", keyWords);
        params.put("page", page);
        params.put("num", num);
        params.put("userId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_TRAINING_BY_KEY_WORDS_NEW, "", params, handler, MSG.MSG_GET_TRAINING_IN_CITY_SUCCESS, MSG.MSG_GET_TRAINING_IN_CITY_FIELD);
    }

    /**
     * 新版签到接口
     *
     * @param activity   上下文
     * @param trainingId 培训id
     * @param handler    回调
     */
    public static void sign(Activity activity, String trainingId, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("trainingId", trainingId);
        params.put("useraccId", UserXML.getUserId(activity));
        params.put("userName", PersonalInfoXML.getTrueName(activity)); // 新增用户真实姓名

        OkHttpUtil.post(activity, URL.URL_SIGN_NEW, "", params, handler, MSG.MSG_SIGN_SUCCESS, MSG.MSG_SIGN_FIELD);
    }


    /**
     * 我的签到列表
     *
     * @param activity
     * @param evaluateStatus “”或者null 签到历史   0待评价
     * @param page
     * @param num
     * @param handler
     */
    public static void getMySignsForMobile(Activity activity, String evaluateStatus, String page, String num, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("evaluateStatus", evaluateStatus);
        params.put("page", page);
        params.put("num", num);
        params.put("useraccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_MY_SIGNS_FOR_MOBILE_NEW, "", params, handler, MSG.MSG_GET_MY_SIGNS_FOR_MOBILE_SUCCESS, MSG.MSG_GET_MY_SIGNS_FOR_MOBILE_FIELD);
    }


}
